package cn.hiapi.admin.api;

import cn.hiapi.admin.query.activity_order.AdminActivityExpandOrderQuery;
import cn.hiapi.admin.vo.activity_order.ActivitySolitaireOrderVo;
import cn.hiapi.basic.controller.BasicQueryController;
import cn.hiapi.interfaces.DispatchContext;
import cn.hiapi.interfaces.user.IUserService;
import cn.hiapi.shopkeeper.entity.order.ActivitySolitaireOrder;
import cn.hiapi.shopkeeper.service.order.ActivitySolitaireOrderService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author AdinZ
 * @date 2023/2/15 23:35
 */
@RestController
@RequestMapping("/manage/activity-order/solitaire")
public class AdminActivitySolitaireController extends BasicQueryController<ActivitySolitaireOrder, Long, ActivitySolitaireOrderVo, AdminActivityExpandOrderQuery> {

    protected AdminActivitySolitaireController(ActivitySolitaireOrderService basicService, DispatchContext dispatchContext) {
        super(basicService, dispatchContext);
    }

    @Override
    public List<ActivitySolitaireOrderVo> toListVo(List<ActivitySolitaireOrder> list, String[] fields) {
        return toList(list, fields);
    }

    @Override
    public ActivitySolitaireOrderVo toData(ActivitySolitaireOrder data, String[] fields) {
        ActivitySolitaireOrderVo vo = data.copy(new ActivitySolitaireOrderVo());
        vo.setUser(this.dispatchContext.getServiceOne(IUserService.class).fieldBase(data.getBuyerId()));
        return vo;
    }
}
